window.onload = function () {

    window.onclick=function(){
        return false;
    }
    let inps=document.querySelectorAll('form input');
    let but=document.querySelector('form button');
    but.onclick=function(){
        let users=inps[0].value;
        let pass=inps[1].value;
        let pass1=inps[2].value;
        let obj={
            "username":users,
            "password":pass
        };
        let s1 = persons.filter(function (item, index) {
            if (item.username == obj.username && item.password == obj.password) {
                return item
            }
        });
         if (s1.length >= 1) {
                    alert('账号已注册，请注册其他账号')
            } else {
                  personsNew.add(obj);
            };
        let persons1=[...personsNew];
        localStorage.username=inps[0].value;
        localStorage.password=inps[1].value;
        console.log(localStorage);
        let s= persons1.filter(function(item,index){
            if((item.username==obj.username &&item.password==obj.password)&&(pass==pass1)){
                return item
            }
       })
       if(s.length>=1){
            alert('注册成功')
            location.href='./login.html'
        }else{
            alert('您输入的两次密码不一致')
        };
    }
}